﻿<%@ WebHandler Language="C#" Class="Upload" %>

using System;
using System.Web;
using System.IO;
using System.Data;
using System.Data.SqlClient;

public class Upload : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        context.Response.Expires = -1;

        string strconn = webapp4U.Configuration.CurrentConnectionString;
        string error = "";
        ClassExecute.ClassExecute dt;
        
        try
        {
            HttpPostedFile postedFile = context.Request.Files["Filedata"];
            
            string savepath = "";
            savepath = webapp4U.Globals.PhysicalApplicationPath() + @"UserUpload\UploadTempFileExcel"; 
            string filename = postedFile.FileName;
            //filename =  webapp4U.Common.GetFileName() + "_" + filename;
            if (!Directory.Exists(savepath))
                Directory.CreateDirectory(savepath);

            webapp4U.FileProcess.DeleteFile(webapp4U.Globals.PhysicalApplicationPath() + "/UserUpload/UploadTempFileExcel/" + filename);
            
            
            postedFile.SaveAs(savepath + @"\" + filename);
            context.Response.Write(filename);
            context.Response.StatusCode = 200;
            
        }
        catch (Exception ex)
        {
            //context.Response.Write("Error: " + ex.Message);
            context.Response.Write("");
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }
}